<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2311：迷宫</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">迷宫</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">迷宫</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                迷宫                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">小Z一觉醒来，发现自己在了一个迷宫之中，苦心探索了若干次，却仍然回到了起点。小Z绝望无比，此时，他决定听天由命。</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">具体来说，这个迷宫有n行m列，小Z现在位于(1,1)，只要走到(n,m)就可以马上离开迷宫。某些格子间有墙而无法通过，迷宫的周围也有一圈墙。而对于可以通过的地方，小Z决定按下述规则移动：在每个格子中，随机选择上下左右四个方向移动，概率由小Z按照自己的方向感确定，当然这个概率会满足下述要求：</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 39pt; text-indent: -18pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">1.</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">有墙的方向概率为0。</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 39pt; text-indent: -18pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">2.</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">除了(n,m)，每个格子往四个方向的概率加起来等于1。</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 39pt; text-indent: -18pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">3.</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">一旦到了(n,m)就马上离开迷宫，故从(n,m)往任意方向的概率均为0。</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-weight: bold; font-size: 12pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">Your&nbsp;Task</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">求出小Z离开迷宫的期望步数。</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: 'Cambria Math'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<!--EndFragment--></p><hr/><h3>输入格式</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">第一行n&nbsp;m表示迷宫大小</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">接下来4个n*m的矩阵，第k个矩阵的第i行第j列的数表示了在格子(i,j)时往k方向移动的概率，k=1为向下(i+1,j)，k=2为向右(i,j+1)，k=3为向上(i-1,j)，k=4为向左(i,j-1)</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">由(n,m)往任意方向走的概率均为0</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: 'Cambria Math'; mso-spacerun: 'yes'"><o:p></o:p></span></p></p><hr/><h3>输出格式</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: left"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: '宋体'; mso-spacerun: 'yes'">输出一个数表示答案，保留三位小数</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify"><span style="font-weight: bold; font-size: 12pt; color: rgb(255,255,255); font-family: '幼圆'; mso-spacerun: 'yes'">样例输入一</span><span style="font-weight: normal; font-size: 10.5pt; color: rgb(255,255,255); font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 10pt; color: rgb(255,255,255); font-family: '宋体'; mso-spacerun: 'yes'">2&nbsp;</span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 10.5pt; color: rgb(0,0,0); font-family: 'Cambria Math'; mso-spacerun: 'yes'"><o:p></o:p></span></p></p><hr/><h3>样例输入</h3><pre>样例输入一
	2 2
	0.1 0.1
	0 0
	0.9 0
	0.1 0
	0 0
	0.9 0
	0 0.9
	0 0
样例输出一
	20.000
样例输入二
	1 5
	0.0 0.0 0.0 0.0 0.0
	1.0 0.1 0.7 0.5 0.0
	0.0 0.0 0.0 0.0 0.0
	0.0 0.9 0.3 0.5 0.0
样例输出二
	41.143</pre><hr/><h3>样例输出</h3><pre></pre><hr/><h3>提示</h3><p><p><br />
100%：1&le;n,m&le;50，迷宫合法，一定可以走到终点，答案不超过10^7<br />
</p></p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2311" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2311" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>